/**
 * 详情对话框
 */
var FlowMemberCommentInfoDlg = {
    data: {
        commentId: "",
        orderId: "",
        memberId: "",
        memberName: "",
        city: "",
        memberPhone: "",
        note: "",
        start: "",
        orderType: "",
        typeName: "",
        imgUrls: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
































    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/flowMemberComment/detail?commentId=" + Feng.getUrlParam("commentId"));
    var result = ajax.start();
    form.val('flowMemberCommentForm', result.data);
    //图片
    if(result.data.imgUrls){
        //图片
        var imgs = result.data.imgUrls.split(",");
        for (var i = 0;i<imgs.length;i++) {
            $("#formList").append("<div class=\"param-line layui-col-md12\">\n" +
                "                                <div class=\"layui-inline\">\n" +
                "                                    <input type='hidden' class='param-value' value='"+imgs[i]+"' />\n" +
                "                                    <img src=\"" + imgs[i] + "\" style=\"width: 240px;display: block;\">\n" +
                "                                </div>\n" +
                "                                <div class=\"layui-inline\">\n" +
                "                                    <i class=\"layui-icon layui-icon-close\" style=\"font-size: 30px; color: #cc0000;\"></i>\n" +
                "                                </div>\n" +
                "                            </div>");
        }
    }
    //
    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {

        //图片
        var imgs = "";
        $("#formList").find('.param-line').each(function () {
            var node = $(this);
            var img = node.find('input.param-value').val();
            if(img){
                if(imgs){
                   imgs += ","+img;
                }else {
                    imgs += img;
                }
            }
        });

        data.field.imgUrls = imgs;

        var ajax = new $ax(Feng.ctxPath + "/flowMemberComment/editItem", function (data) {
            Feng.success("更新成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    $("#formList").on('click','.layui-icon-close',function () {
        $(this).parents('.param-line').remove();
    });
});